CREATE TABLE [dbo].[tb_Zonas]
(
[idZona] [int] NOT NULL IDENTITY(1, 1),
[zona] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ALosEfectosDe] [int] NOT NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[updatetb_Zonas] ON [dbo].[tb_Zonas]
 FOR UPDATE AS 
SET NOCOUNT ON
 IF (update(idZona)) begin 
	 SELECT * FROM inserted 
	 IF @@ROWCOUNT = 1 begin 
		 UPDATE tb_SubOrganizaciones
		 SET Zona = (SELECT idZona FROM inserted)
		 WHERE tb_SubOrganizaciones.Zona = (SELECT idZona FROM deleted)
	end  ELSE begin 
		 ROLLBACK TRANSACTION 
 end 
 end

GO
ALTER TABLE [dbo].[tb_Zonas] ADD CONSTRAINT [PK_tb_zonas] PRIMARY KEY CLUSTERED  ([idZona]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_Zonas] WITH NOCHECK ADD CONSTRAINT [FK_tb_zonas_tb_EfectosDeZonas] FOREIGN KEY ([ALosEfectosDe]) REFERENCES [dbo].[tb_EfectosDeZonas] ([idEfectoDeZona])
GO
